package com.example.webservice.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class OracleGenericDAO {
//static final String STRING_CONECTION = "jdbc:oracle:thin:@200.247.254.2:1522:WINT";
static final String STRING_CONECTION = "jdbc:oracle:thin:@200.247.254.XXX:1521:WINT";//,udar final IP
static final String USERNAME ="XXXXXXXX";//mudar senha
static final String PASSWORD ="XXXXXXXXX";// mudar password

protected Connection getConnection() throws SQLException {
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
      Connection connection = DriverManager.getConnection(STRING_CONECTION, USERNAME, PASSWORD);
      return connection;
      
   }
protected void close(ResultSet rs) {
    if (rs !=null) {
       try {
          rs.close();               
       } catch (Exception e) {
          e.printStackTrace();
       }
    }      
 }

 protected void close(PreparedStatement pstmt) {
    if (pstmt !=null) {
       try {
          pstmt.close();               
       } catch (Exception e) {
          e.printStackTrace();
       }
    }      
 }

 protected void close(Connection connection) {
    if (connection !=null) {
       try {
          connection.close();               
       } catch (Exception e) {
          e.printStackTrace();
       }
    }      
 }
}